import { defineStore } from "pinia";

// 存储标签导航栏
const TagsAndBreadStore = defineStore('tags&bread', {
    state: () => ({
        tags: [{ path: '/home', title: '首页', type: 'plain', isClose: false }],
        breadcrumb: []
    }),
    actions: {
        Tags(data) {
            // 检查是否已存在相同数据
            const isDuplicate = this.tags.some(item => item.path === data.path && item.title === data.title);

            // 不存在相同数据时才进行添加
            if (!isDuplicate) {
                this.tags.push(data);
            }
        },
        BreadCrumb(data) {
            this.breadcrumb = data;
        }
    },
})

export default TagsAndBreadStore;